package com.heima.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping("/testModelAndView")
    public ModelAndView testModelAndView(ModelAndView modelAndView){
        modelAndView.addObject("nowDate", new Date());
        modelAndView.addObject("msg", "hello");

        modelAndView.setViewName("forward:/pages/message.jsp");

        return modelAndView;
    }

    @RequestMapping("/testModelAndView2")
    public ModelAndView testModelAndView2(ModelAndView modelAndView){
        modelAndView.addObject("nowDate", new Date());
        modelAndView.addObject("msg", "hello");

        modelAndView.setViewName("forward:/pages/message.jsp");
        System.out.println(1/0);
        return modelAndView;
    }

}
